package com.wzz.seckillone.controller;


import com.alibaba.fastjson.JSON;
import com.wzz.seckillone.common.AjaxResult;
import com.wzz.seckillone.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jobob
 * @since 2021-11-08
 */
@Controller
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/detail")
    @ResponseBody
    public String getOrderDetailByOrderId(String orderId){
        AjaxResult result = new AjaxResult();
        try{
            result.setSuccess(true).setData(orderService.getOrderByOrderId(orderId)).setMessage("查询成功");
        }catch(Exception e){
            result.setSuccess(false).setMessage("查询失败"+e.getMessage());
        }
        return JSON.toJSONString(result);
    }
}
